Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /*jslint |
||
254 | Markers.createMarkerDiv = function (id) { |
||
255 | 'use strict'; |
||
256 | |||
257 | var iconw = 33, |
||
258 | iconh = 37, |
||
259 | offsetx = (id % 26) * iconw, |
||
260 | offsety = Math.floor(id / 26) * iconh; |
||
261 | |||
262 | return "<div id=\"dyn" + id + "\">" + |
||
263 | "<table class=\"view\" style=\"width: 100%; vertical-align: middle;\">\n" + |
||
264 | " <tr>\n" + |
||
265 | " <td rowspan=\"3\" style=\"vertical-align: top\">\n" + |
||
266 | " <span style=\"width:" + iconw + "px; height:" + iconh + "px; float: left; display: block; background-image: url(img/markers.png); background-repeat: no-repeat; background-position: -" + offsetx + "px -" + offsety + "px;\"> </span>\n" + |
||
267 | " </td>\n" + |
||
268 | " <td style=\"text-align: center\"><i class=\"fa fa-map-marker\"></i></td>\n" + |
||
269 | " <td class\"name\" colspan=\"2\">marker</td>\n" + |
||
270 | " </tr>\n" + |
||
271 | " <tr>\n" + |
||
272 | " <td style=\"text-align: center\"><i class=\"fa fa-globe\"></i></td>\n" + |
||
273 | " <td class=\"coords\" colspan=\"2\">N 48° 00.123 E 007° 51.456</td>\n" + |
||
274 | " </tr>\n" + |
||
275 | " <tr>\n" + |
||
276 | " <td style=\"text-align: center\"><i class=\"fa fa-circle-o\"></i></td>\n" + |
||
277 | " <td class=\"radius\">16100 m</td>\n" + |
||
278 | " <td>\n" + |
||
279 | " <div class=\"btn-group\" style=\"padding-bottom: 2px; padding-top: 2px; float: right\">\n" + |
||
280 | " <button class=\"my-button btn btn-mini btn-warning\" data-i18n=\"[title]sidebar.markers.edit_marker\" type=\"button\" onclick=\"Markers.enterEditMode(" + id + ");\"><i class=\"fa fa-edit\"></i></button>\n" + |
||
281 | " <button class=\"my-button btn btn-mini btn-danger\" data-i18n=\"[title]sidebar.markers.delete_marker\" type=\"button\" onClick=\"Markers.removeById(" + id + ");\"><i class=\"fa fa-trash-o\"></i></button>\n" + |
||
282 | " <button class=\"my-button btn btn-mini btn-info\" data-i18n=\"[title]sidebar.markers.move_to\" type=\"button\" onClick=\"Markers.goto(" + id + ");\"><i class=\"fa fa-search\"></i></button>\n" + |
||
283 | " <button class=\"my-button btn btn-mini btn-warning\" data-i18n=\"[title]sidebar.markers.center\" type=\"button\" onClick=\"Markers.center(" + id + ");\"><i class=\"fa fa-crosshairs\"></i></button>\n" + |
||
284 | " <button class=\"my-button btn btn-mini btn-success\" data-i18n=\"[title]sidebar.markers.project\" type=\"button\" onClick=\"projectFromMarker(" + id + ");\"><i class=\"fa fa-location-arrow\"></i></button>\n" + |
||
285 | " </div>\n" + |
||
286 | " </td>\n" + |
||
287 | " </tr>\n" + |
||
288 | "</table>\n" + |
||
289 | "<table class=\"edit\" style=\"display: none; width: 100%; vertical-align: middle;\">\n" + |
||
290 | " <tr>\n" + |
||
291 | " <td rowspan=\"4\" style=\"vertical-align: top\"><span style=\"width:" + iconw + "px; height:" + iconh + "px; float: left; display: block; background-image: url(img/markers.png); background-repeat: no-repeat; background-position: -" + offsetx + "px -" + offsety + "px;\"> </span>\n" + |
||
292 | " <td style=\"text-align: center; vertical-align: middle;\"><i class=\"icon-map-marker\"></i></td>\n" + |
||
293 | " <td><input data-i18n=\"[title]sidebar.markers.name;[placeholder]sidebar.markers.name_placeholder\" class=\"name form-control input-block-level\" type=\"text\" style=\"margin-bottom: 0px;\" value=\"n/a\" /></td>\n" + |
||
294 | " </tr>\n" + |
||
295 | " <tr>\n" + |
||
296 | " <td style=\"text-align: center; vertical-align: middle;\"><i class=\"icon-globe\"></i></td>\n" + |
||
297 | " <td><input data-i18n=\"[title]sidebar.markers.coordinates;[placeholder]sidebar.markers.coordinates_placeholder\" class=\"coords form-control input-block-level\" type=\"text\" style=\"margin-bottom: 0px;\" value=\"n/a\" /></td>\n" + |
||
298 | " </tr>\n" + |
||
299 | " <tr>\n" + |
||
300 | " <td style=\"text-align: center; vertical-align: middle;\"><i class=\"icon-circle-blank\"></i></td>\n" + |
||
301 | " <td><input data-i18n=\"[title]sidebar.markers.radius;[placeholder]sidebar.markers.radius_placeholder\" class=\"radius form-control input-block-level\" type=\"text\" style=\"margin-bottom: 0px;\" value=\"n/a\" /></td>\n" + |
||
302 | " </tr>\n" + |
||
303 | " <tr>\n" + |
||
304 | " <td colspan=\"2\" style=\"text-align: right\">\n" + |
||
305 | " <button class=\"btn btn-small btn-primary\" type=\"button\" onclick=\"Markers.leaveEditMode(" + id + ", true);\" data-i18n=\"dialog.ok\">OK</button>\n" + |
||
306 | " <button class=\"btn btn-small\" type=\"button\" onclick=\"Markers.leaveEditMode(" + id + ", false);\" data-i18n=\"dialog.cancel\">CANCEL</button>\n" + |
||
307 | " </td>\n" + |
||
308 | " </tr>\n" + |
||
309 | "</table>" + |
||
310 | "</div>"; |
||
311 | }; |
||
312 | |||
369 |